/**
 * \file Cpu_Main.h
 * \brief System initialization and main program implementation.
 *
 * \copyright Copyright (c) 2019 Infineon Technologies AG. All rights reserved.
 *
 *
 *
 *                                 IMPORTANT NOTICE
 *
 *
 * Use of this file is subject to the terms of use agreed between (i) you or
 * the company in which ordinary course of business you are acting and (ii)
 * Infineon Technologies AG or its licensees. If and as long as no such
 * terms of use are agreed, use of this file is subject to following:


 * Boost Software License - Version 1.0 - August 17th, 2003

 * Permission is hereby granted, free of charge, to any person or
 * organization obtaining a copy of the software and accompanying
 * documentation covered by this license (the "Software") to use, reproduce,
 * display, distribute, execute, and transmit the Software, and to prepare
 * derivative works of the Software, and to permit third-parties to whom the
 * Software is furnished to do so, all subject to the following:

 * The copyright notices in the Software and this entire statement, including
 * the above license grant, this restriction and the following disclaimer, must
 * be included in all copies of the Software, in whole or in part, and all
 * derivative works of the Software, unless such copies or derivative works are
 * solely in the form of machine-executable object code generated by a source
 * language processor.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.

 *
 */

#ifndef CPU_MAIN_H
#define CPU_MAIN_H

/******************************************************************************/
/*----------------------------------Includes----------------------------------*/
/******************************************************************************/
#include "Configuration.h"
#include <Cpu/Std/Ifx_Types.h>
/******************************************************************************/
/*-----------------------------------Macros-----------------------------------*/
/******************************************************************************/

/******************************************************************************/
/*------------------------------Type Definitions------------------------------*/
/******************************************************************************/
typedef struct
{
    float32 sysFreq;                /**< \brief Actual SPB frequency */
    float32 cpuFreq;                /**< \brief Actual CPU frequency */
    float32 pllFreq;                /**< \brief Actual PLL frequency */
    float32 stmFreq;                /**< \brief Actual STM frequency */
} AppInfo;

/** \brief Application information */
typedef struct
{
    AppInfo info;                               /**< \brief Info object */
    uint32 TickCount_1ms;                       /**< \brief TickCount 1ms */
} App_Cpu;

/******************************************************************************/
/*------------------------------Global variables------------------------------*/
/******************************************************************************/
IFX_EXTERN volatile uint32 Ethernet_Phy_Id1;
IFX_EXTERN volatile uint32 Ethernet_Phy_Id2;
IFX_EXTERN volatile boolean Phy_IdRed;
IFX_EXTERN App_Cpu g_AppCpu0;
IFX_EXTERN volatile uint32 cpu0_idle_counter;
IFX_EXTERN volatile uint32 cpu0_ccnt_diff_min;

#if (IFXCPU_NUM_MODULES > 1)
#if defined(__DCC__)
#pragma section DATA ".data_cpu1" ".bss_cpu1" far-absolute RW
#endif

IFX_EXTERN App_Cpu g_AppCpu1;
IFX_EXTERN volatile uint32 cpu1_idle_counter;
IFX_EXTERN volatile uint32 cpu1_ccnt_diff_min;

#endif

#if (IFXCPU_NUM_MODULES > 2)
#if defined(__DCC__)
#pragma section DATA ".data_cpu2" ".bss_cpu2" far-absolute RW
#endif

IFX_EXTERN App_Cpu g_AppCpu2;
IFX_EXTERN volatile uint32 cpu2_idle_counter;
IFX_EXTERN volatile uint32 cpu2_ccnt_diff_min;

#endif

#if (IFXCPU_NUM_MODULES > 3)
#if defined(__DCC__)
#pragma section DATA ".data_cpu3" ".bss_cpu3" far-absolute RW
#endif

IFX_EXTERN App_Cpu g_AppCpu3;
IFX_EXTERN volatile uint32 cpu3_idle_counter;
IFX_EXTERN volatile uint32 cpu3_ccnt_diff_min;

#endif

#if (IFXCPU_NUM_MODULES > 4)
#if defined(__DCC__)
#pragma section DATA ".data_cpu4" ".bss_cpu4" far-absolute RW
#endif

IFX_EXTERN App_Cpu g_AppCpu4;
IFX_EXTERN volatile uint32 cpu4_idle_counter;
IFX_EXTERN volatile uint32 cpu4_ccnt_diff_min;

#endif

#if (IFXCPU_NUM_MODULES > 5)
#if defined(__DCC__)
#pragma section DATA ".data_cpu5" ".bss_cpu5" far-absolute RW
#endif

IFX_EXTERN App_Cpu g_AppCpu5;
IFX_EXTERN volatile uint32 cpu5_idle_counter;
IFX_EXTERN volatile uint32 cpu5_ccnt_diff_min;

#endif

#if defined(__DCC__)
#pragma section DATA RW
#endif
#endif
